import matplotlib.pyplot as ply

from screen import Screen
from function import cThread


class myScreen(Screen):
    def __init__(self):
        Screen.__init__(self)
        self.threads = []
        ply.plot()

    def doOperation(self):
        print("开始运算")
        t = cThread()
        t.start()
        self.threads.append(t)

    def stopOperation(self):
        for item in self.threads:
            item.stop()
        print("停止运算")

    def showResult(self):
        ply.clf()
        num = 0
        for item in self.threads:
            print(num)
            x, y = item.showTable()
            num += y[-1]
            ply.plot(x, y)
        self.threads = []
        self.v.set(num)
        ply.show()


if __name__ == '__main__':
    screen = myScreen()
    screen.run()
